﻿#include "CreatePDF.h"
#include <io.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <setjmp.h>

CreatePDF::CreatePDF()
{

}

CreatePDF::~CreatePDF()
{

}

//生成PDF文档
PSignData CreatePDF::CreateDocument_libharu(PCreateDataPDF pData)
{
    PSignData rSign = NULL;//签字标定数据
    string FileName = pData->RootPath + "/" + pData->FileName;
    DrawTable* DrawClass = new DrawTable(FileName);
    rSign = DrawClass->DrawDocument(pData);
    delete DrawClass;

    return rSign;
}
//生成PDF封面
PSignData CreatePDF::CreateCover_libharu(PCreateDataPDF pData)
{
    PSignData rSign = NULL;//签字标定数据
    string FileName = pData->FileName;
    DrawTable* DrawClass = new DrawTable(FileName);
    rSign = DrawClass->DrawCover(pData);
    delete DrawClass;

    return rSign;
}
//生成PDF标签
PSignData CreatePDF::CreateLabel_libharu(PCreateDataPDF pData)
{
    PSignData rSign = NULL;//签字标定数据
    string FileName = pData->RootPath + "/" + pData->FileName;
    DrawTable* DrawClass = new DrawTable(FileName);
    rSign = DrawClass->DrawLabel(pData);
    delete DrawClass;

    return rSign;
}

wstring CreatePDF::s2ws(const string& s) {
    size_t convertedChars = 0;
    string curLocale = setlocale(LC_ALL, NULL);//curLocale="C"
    setlocale(LC_ALL, "chs");
    const char* source = s.c_str();
    size_t charNum = sizeof(char) * s.size() + 1;
    wchar_t* dest = new wchar_t[charNum];
    mbstowcs_s(&convertedChars, dest, charNum, source, _TRUNCATE);
    wstring result = dest;
    delete[] dest;
    setlocale(LC_ALL, curLocale.c_str());
    return result;
}